extensions: add rgba8_rgb8 conversion that copies 24/32bit chunks
authorØyvind Kolås <pippin@gimp.org>
Wed, 4 Apr 2018 12:09:54 +0000 (14:09 +0200)
committerØyvind Kolås <pippin@gimp.org>
Wed, 4 Apr 2018 12:14:05 +0000 (14:14 +0200)
Slightly speeding up RGB u8 (without alpha) painting in GIMP, the rgba to rgb
and reverse conversions are used together with the very fast SIMD conversions
that operate on chunks of 4 components.

extensions/gegl-fixups.c

index e3bb836d640123a48f92155fd00a73cdae197b3e..d6ad91212ddb2b97efd727c6e3112354f0a708e1 100644 (file)
@@ -447,6 +447,22 @@ conv_rgbAF_lrgba8 (const Babl *conversion,unsigned char *srcc,
     }
 }
 
+static void
+conv_rgba8_rgb8 (const Babl *conversion,unsigned char *src, unsigned char *dst, long samples)
+{
+  long n = samples - 1;
+
+  while (n--)
+    {
+      *(unsigned int *) dst = (*(unsigned int *) src);
+      src   += 3;
+      dst   += 4;
+    }
+  dst[0] = src[0];
+  dst[1] = src[1];
+  dst[2] = src[2];
+}
+
 #define conv_rgb8_rgbAF    conv_rgb8_rgbaF
 #define conv_gamma_rgbaF_gamma_rgbAF   conv_rgbaF_rgbAF
 #define conv_gamma_rgbAF_gamma_rgbaF   conv_rgbAF_rgbaF
@@ -531,10 +547,8 @@ init (void)
 
   o (rgbaF, rgbAF);
   o (rgbAF, rgbaF);
-  
   o (gamma_rgbaF, gamma_rgbAF);
   o (gamma_rgbAF, gamma_rgbaF);
-  
   o (rgbAF, lrgba8);
   o (rgb8,  rgbaF);
   o (rgb8,  rgbAF);
@@ -542,6 +556,7 @@ init (void)
   o (rgbaF, rgb8);
   o (rgbAF, rgb8);
   o (bgrA8, rgba8);
+  o (rgba8, rgb8);
 
   return 0;
 }